//
//  YijianfankuiViewController.swift
//  fruit-helper-swift
//
//  Created by 赵隆杰 on 2022/7/11.
//

import UIKit
import Toast

class YijianfankuiViewController: BaseViewController {
    
    
    @IBOutlet weak var textView: UITextView!
    @IBOutlet weak var submitButton: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        navigationItem.title = "意见反馈"
        
        submitButton.layer.cornerRadius = submitButton.height/2
        submitButton.layer.masksToBounds = true
    }

    @IBAction func submitClick(_ sender: UIButton) {
        
        view.endEditing(true)

        if (textView.text.count == 0) {
            UIWindow().currentWindow()?.makeToast("请填写意见", duration: 1.0, position: CSToastPositionCenter)
            return;
        }
        
        DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
            self.navigationController?.popViewController(animated: true)
            UIWindow().currentWindow()?.makeToast("添加成功！", duration: 2.0, position: CSToastPositionCenter)
            
            let alert = UIAlertController(title: nil, message: "您的宝贵意见已提交", preferredStyle: .alert)
            let cancel = UIAlertAction(title: "确认", style: .cancel) { action in
                self.navigationController?.popViewController(animated: true)
            }
            alert.addAction(cancel)
            UIWindow().currentViewController()?.present(alert, animated: true, completion: nil)
        }
        
    }
    
}
